<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							订单编号：<input type="text" name="formNum" id="formNum"/>
						</li>
						<li>
							归属平台：<select   name="deptId" id="deptId">
								<option value="">请选择归属平台</option>
							</select>

						</li>

						<li id="create">
							录单员：<select   name="createBy" id="createBy">
                            <option value="">请选择录单员</option>
                        </select>
						</li>
						<li>
							旺旺号：<input type="text" name="wwNum" id="wwNum"/>
						</li>
						<li>
							微信号：<input type="text" name="webChatNum" id="webChatNum"/>
						</li>
						<li>
							<!--订单性质：<input type="text" name="webChatNum" />-->
							订单性质：<select name="formNature" th:with="type=${@dict.getType('form_state')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
					</ul>
					<ul>
						<li>
							产品：<select   name="enterProductId" id="enterProductId">
							<option value="">请选择产品</option>
						</select>
						</li>
						<li class="select-time">
							<label>录入时间： </label>
							<input type="text" class="time-input" id="beginTime" placeholder="开始时间" name="beginTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">

			<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="enter:enter:import">
				<i class="fa fa-upload"></i> 导入
			</a>
			<a class="btn btn-info" onclick="$.table.importExcel1()" shiro:hasPermission="enter:enter:newImport">
				<i class="fa fa-plus"></i> 新导入
			</a>
			<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="enter:enter:add">
				<i class="fa fa-plus"></i> 录入
			</a>


			<!--<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="enter:enter:checkAll">-->
				<!--<i class="fa fa-check"></i> 审核-->
			<!--</a>-->
			<a class="btn btn-warning" onclick="exportExcel()" >
				<i class="fa fa-download"></i> 导出
			</a>
			<a class="btn btn-danger btn-del disabled" onclick="batchDelete()" shiro:hasPermission="enter:enter:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('enter:enter:edit')}]];
    var removeFlag = [[${@permission.hasPermi('enter:enter:remove')}]];
    var prefix = ctx + "enter/enter";

    $(function () {
        getAllProduct()
        getAllDept()
        getAllEnterUser()
        getroleid()
    })


    // 查询所有的产品名称
    function getAllProduct() {
        $.ajax({
            type: "GET",
            url: prefix +'/allProduct',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                console.log(data)
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
                    $("#enterProductId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }

    // 获取所有的平台信息
    function getAllDept() {
        $.ajax({
            type: "GET",
            url: prefix +'/allDeptT',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                console.log(data)
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].deptId+"'>"+data[i].deptName + "</opinion>"
                    $("#deptId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }

    // 获取所有的录单员
    function getAllEnterUser() {
        $.ajax({
            type: "GET",
            url: prefix +'/getUserByRoeId',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].userId+"'>"+data[i].userName + "</opinion>"
                    $("#createBy").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }
	//获取角色id
    function getroleid() {
        $.ajax({
            type: "GET",
            url: prefix +'/getroleid',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                console.log(data)
                if (data=="4"){
					$("#create").css("display","none")
				}
                // for(var i=0;i<data.length;i++){
                //     var html = "<option value='"+data[i].userId+"'>"+data[i].userName + "</opinion>"
                //     $("#createBy").append(html);
                // }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }


    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
            importUrl: prefix + "/importData",
            importUrl1: prefix + "/newImportData",
            checkAllUrl: prefix + "/checkAll",
            importTemplateUrl: prefix + "/importTemplate",
            uniqueId: "id",
            // exportUrl: prefix + "/export",
            // sortName: "roleSort",
            modalName: "订单基本信息",
            columns: [
				{
					checkbox: true
				},
                {
                    field: 'Number',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    },
                },
                {
                    field: 'id',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'enterName',
                    title: '录单员',
                },
                {
                    field: 'createDate',
                    title: '日期',
                },
                {
                    field: 'deptName',
                    title: '平台',
                },
                {
                    field: 'shopName',
                    title: '店铺',
                },
                {
                    field: 'formNum',
                    title: '订单号',
                },
                {
                    field: 'productName',
                    title: '产品名称',
                },
                {
                    field: 'orderPrice',
                    title: '订单金额',
                },
                {
                    field: 'commission',
                    title: '佣金',
                },
                {
                    field: 'wwNum',
                    title: '旺旺号',
					formatter:function (value, row, index) {
						if (row.customerColor == 1){
						    return "<span style='color: red;'>"+ row.wwNum + "</span>"
						}else if (row.customerColor == 2){
                            return "<span style='color: #800080;'>"+ row.wwNum + "</span>"

                        }else{
                            return "<span >"+ row.wwNum + "</span>"

                        }
                    }
                },
                {
                    field: 'webChatNum',
                    title: '微信号',
                },
                {
                    field: 'goodRecord',
                    title: '好评数',
                },
                {
                    field: 'goodPrice',
                    title: '好评单价',
                },
                {
                    field: 'formNature',
                    title: '订单性质',
                },
                {
                    field: 'remark',
                    title: '备注',
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index)  {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function exportExcel(){

        window.location.href =prefix+'/exportExcel?formNum='+$("#formNum").val()+"&deptId="+$("#deptId").val() +"&createBy="+$("#createBy").val()+"&wwNum="+$("#wwNum").val()+"&webChatNum="+$("#webChatNum").val()+ "&enterProductId="+$("#enterProductId").val()+"&beginTime="+$("#beginTime").val()+"&endTime="+$("#endTime").val() ;
    }

	// 审核订单信息
	function batchDelete() {
		var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		$.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
			var url = prefix + "/remove";
			var data = { "ids": rows.join() };
			$.operate.submit(url, "post", "json", data);
		});
	}






</script>
</body>
<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
	<div class="col-xs-offset-1">
		<input type="file" id="file" name="file"/>
		<!--<div class="mt10 pt5">-->
			<!--<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据-->
			<!--&nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>-->
		<!--</div>-->
		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>

<form id="importForm1" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
	<div class="col-xs-offset-1">
		<input type="file" id="file1" name="file"/>
		<!--<div class="mt10 pt5">-->
		<!--<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据-->
<!--			<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>-->
		<!--</div>-->
		<font color="red" class="pull-left mt10">
			提示：仅允许导入“xls”或“xlsx”格式文件！
		</font>
	</div>
</form>
</html>